package com.yunke.common.exception;

import com.yunke.common.result.YunkeResultCode;

/**
 * 云科搭子系统自定义业务异常
 * 
 * @author yunke
 * @since 1.0.0
 */
public class YunkeException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    private Integer code;

    /**
     * 错误信息
     */
    private String message;

    public YunkeException() {
        super();
    }

    public YunkeException(String message) {
        super(message);
        this.message = message;
        this.code = YunkeResultCode.FAILURE.getCode();
    }

    public YunkeException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public YunkeException(YunkeResultCode resultCode) {
        super(resultCode.getMessage());
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
    }

    public YunkeException(YunkeResultCode resultCode, String message) {
        super(message);
        this.code = resultCode.getCode();
        this.message = message;
    }

    public YunkeException(Throwable cause) {
        super(cause);
        this.code = YunkeResultCode.FAILURE.getCode();
        this.message = cause.getMessage();
    }

    public YunkeException(String message, Throwable cause) {
        super(message, cause);
        this.code = YunkeResultCode.FAILURE.getCode();
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public String toString() {
        return "YunkeException{" +
                "code=" + code +
                ", message='" + message + '\'' +
                '}';
    }
} 